package com.xhh.stu.cal.factory;

import com.xhh.stu.cal.Calculate;
import com.xhh.stu.cal.impl.CalculateAdd;
import com.xhh.stu.cal.impl.CalculateDiv;
import com.xhh.stu.cal.impl.CalculateMul;
import com.xhh.stu.cal.impl.CalculateSub;

/**
 * 计算器工厂
 * <p>2017年1月4日 下午4:38:03</p>
 * @author lijian
 * @version 1.0
 */
public class CalculateFactory {

	/**
	 * 
	 * @param operation
	 * @return
	 */
	public static Calculate getCalCulateInstance(String operation) {
		Calculate cal = null;// ������
		switch (operation) {
		case "+":
			cal = new CalculateAdd();
			break;
		case "-":
			cal = new CalculateSub();
			break;
		case "*":
			cal = new CalculateMul();
			break;
		case "/":
			cal = new CalculateDiv();
			break;
		default:
			System.err.println("don't support operation,please check it!");
			break;
		}
		return cal;
	}
}
